package com.chenqq.qsocket.message;

import android.text.TextUtils;

import java.util.Arrays;

/**
 * 心跳包消息
 * body:{ "type":"0"}  相互心跳的相应和请求内容不能呢相同
 *
 */
public class KeepAliveMessage extends SocketMessage {
    public KeepAliveMessage(SocketMessage msg) {
        super(msg);
    }

    public KeepAliveMessage(String body){
        setBody(body);
        setType(SocketMessage.TYPE_HEART_BEAT);
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof SocketMessage){
            SocketMessage other = (SocketMessage)o;
            String jsonBody = other.getJSONBody();
            return !TextUtils.isEmpty(jsonBody) && getJSONBody().equals(jsonBody);
        }
        if (o instanceof String){
            return getJSONBody().equals(o);
        }
        return false;
    }


}
